﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using IndoReputation.Models.BusinessObject;
using IndoReputation.Models.BusinessObject.Collections;
using IndoReputation.Models.DataAccess;

namespace IndoReputation.Models.BusinessLogic
{
    public class OfficeCEOBOL
    {
        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 4/22/2012  6:03 PM
        /// Todo: Insert an officeCEO to db
        /// </summary>
        /// <param name="officeCEO">The officeCEO.</param>
        /// <returns></returns>
        public static int Insert(OfficeCEO officeCEO)
        {
            try
            {
                officeCEO.CreateAt = DateTime.Now;
                officeCEO.CreateBy = MySession.UserID;
                officeCEO.UpdateAt = null;
                officeCEO.UpdateBy = null;
                return OfficeCEODAL.Insert(officeCEO);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }

        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 11/30/2011  9:45 AM
        /// Todo: Update a User Exists in Database 
        /// </summary>
        /// <param name="officeCEO">A officeCEO.</param>
        /// <returns></returns>
        public static bool Update(OfficeCEO officeCEO)
        {
            try
            {
                officeCEO.UpdateAt = DateTime.Now;
                officeCEO.UpdateBy = MySession.UserID;
                return OfficeCEODAL.Update(officeCEO);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }

        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 11/30/2011  10:36 AM
        /// Todo: Delete a User Existst in Database
        /// </summary>
        /// <param name="officeCEO">A officeCEO.</param>
        /// <returns></returns>
        public static bool Delete(int officeCEOID)
        {
            try
            {
                return OfficeCEODAL.Delete(officeCEOID);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }

        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 11/29/2011  5:23 PM
        /// Todo: Get All OfficeCEO
        /// </summary>
        /// <returns></returns>
        public static OfficeCEOList GetAllOfficeCEO()
        {
            try
            {
                return OfficeCEODAL.GetAllOfficeCEO() ?? new OfficeCEOList();
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }

        /// <summary>
        /// Author: Nguyen Duc Thanh Tung
        /// Created on: 11/30/2011  10:40 AM
        /// Todo: Select a User existst in Database
        /// </summary>
        /// <param name="officeCEOID">The officeCEO ID.</param>
        /// <returns></returns>
        public static OfficeCEO GetOfficeCEOById(int officeCEOID)
        {
            try
            {
                return OfficeCEODAL.GetOfficeCEOById(officeCEOID);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }

        public static bool Update(OfficeCEOJoin officeCEO)
        {
            try
            {
                officeCEO.CreateAt = DateTime.Now;
                officeCEO.CreateBy = MySession.UserID;
                officeCEO.UpdateAt = DateTime.Now;
                officeCEO.UpdateBy = MySession.UserID;
                return OfficeCEODAL.Update(officeCEO);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }
    }
}